﻿<UserControl
    x:Class="XamlInspector.Presentation.VisualTreeControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" x:Name="root"
    d:DesignHeight="300"
    d:DesignWidth="400">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <ListBox x:Name="listBox" Grid.Row="1" ItemsSource="{Binding VisualTreeItems, ElementName=root}" SelectedValuePath="Element" SelectedValue="{Binding SelectedElement, ElementName=root, Mode=TwoWay}" SelectionMode="Single" Padding="4,4,20,20"
                 BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollMode="Enabled" ItemContainerStyle="{StaticResource VisualTreeItemStyle}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="{Binding Margin}" >
                        <ToolTipService.ToolTip>
                            <Image Height="150" Width="150" Source="{Binding Preview}" />
                        </ToolTipService.ToolTip>
                        <ToggleButton Style="{StaticResource ExpandCollapseToggleButtonStyle}" Width="16" Height="16" Margin="0,3,2,0" Background="LightGray" IsChecked="{Binding IsExpanded, Mode=TwoWay}" VerticalAlignment="Center" Content="o"/>
                        <Image Source="{Binding Icon}" Stretch="None" Width="16" />
                        <TextBlock FontWeight="{Binding FontWeight}" Text="{Binding Element.Text}" Margin="8,0,0,0" FontSize="14" />
                        <TextBlock Text="{Binding Element.TotalCount}" Margin="8,0,0,0" Foreground="DarkGray" FontSize="14" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
